<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绝对定位的左右居中</title>
</head>
<style>
    body {
        border: 0;
        padding: 0;
        margin: 0;
    }

    .box {
        height: 100vh;
    }

    .center {
        border: 1px solid black;
        position: absolute;
        width: 200px;
        height: 100px;
        margin: 0 auto;
        left: 0;
        right: 0;
    }
</style>

<body>
    <div class="box">
        <div class="center"></div>
    </div>
</body>

</html>